<?php

declare(strict_types=1);

namespace Plugin\Attractions\HaiKang\Model;

use Hyperf\DbConnection\Model\Model as MineModel;

/**
 * @property string $group_id 组id
 * @property string $group_name 组名称
 * @property string $group_no 组编号
 * @property string $parent_id 父节点id
 * @property \Carbon\Carbon $created_at
 * @property \Carbon\Carbon $updated_at
 */
class HkDeviceGroup extends MineModel
{
    /**
     * The table associated with the model.
     */
    protected ?string $table = 'hk_device_group';

    protected string $keyType = 'string';

    protected string $primaryKey = 'group_id';

    /**
     * The attributes that are mass assignable.
     */
    protected array $fillable = ['group_id', 'group_name', 'group_no', 'parent_id', 'created_at', 'updated_at'];

    /**
     * The attributes that should be cast to native types.
     */
    protected array $casts = ['group_id' => 'string', 'group_name' => 'string', 'group_no' => 'string', 'parent_id' => 'string', 'created_at' => 'datetime', 'updated_at' => 'datetime'];

    public function devices()
    {
        return $this->hasMany(HkDevice::class, 'group_id', 'group_id');
    }
}
